﻿using System;
using System.Collections.Generic;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.pp.mediator;
using SharpSqlAnalyzer.pp.mediator.type;
using SharpSqlAnalyzer.pp.para;
using SharpSqlAnalyzer.pp.processor.type.comm;

namespace SharpSqlAnalyzer.pp.stmtformatter.type
{
	// Token: 0x020001FC RID: 508
	public class AbstractStmtFormatter
	{
		// Token: 0x17000346 RID: 838
		// (get) Token: 0x060011D4 RID: 4564 RVA: 0x0031655E File Offset: 0x0031475E
		public virtual GFmtOpt Option
		{
			get
			{
				return GFmtOptFactory.newInstance(this.sessionId);
			}
		}

		// Token: 0x060011D5 RID: 4565 RVA: 0x0031656B File Offset: 0x0031476B
		public virtual void format(TCustomSqlStatement stmt)
		{
			this.beforeFormat(stmt);
			this.doFormat(stmt);
			this.afterFormat(stmt);
		}

		// Token: 0x060011D6 RID: 4566 RVA: 0x00316582 File Offset: 0x00314782
		protected internal virtual void beforeFormat(TCustomSqlStatement stmt)
		{
			MediatorFactory.getMediator<KeywordAlignMediator>(typeof(KeywordAlignMediator), this.sessionId).increaseLevel();
		}

		// Token: 0x060011D7 RID: 4567 RVA: 0x0031659E File Offset: 0x0031479E
		protected internal virtual void doFormat(TCustomSqlStatement stmt)
		{
		}

		// Token: 0x060011D8 RID: 4568 RVA: 0x003165A0 File Offset: 0x003147A0
		protected internal virtual void afterFormat(TCustomSqlStatement stmt)
		{
			MediatorFactory.getMediator<KeywordAlignMediator>(typeof(KeywordAlignMediator), this.sessionId).decreaseLevel();
		}

		// Token: 0x060011D9 RID: 4569 RVA: 0x003165BC File Offset: 0x003147BC
		protected internal virtual void runProcessor<T>(IList<AbstractProcessor> processors, T node) where T : TParseTreeNode
		{
			if (processors == null || processors.Count == 0)
			{
				return;
			}
			for (int i = 0; i < processors.Count; i++)
			{
				processors[i].beforeProcess(node);
			}
			for (int j = 0; j < processors.Count; j++)
			{
				processors[j].process(node);
			}
			for (int k = processors.Count - 1; k >= 0; k--)
			{
				processors[k].afterProcess(node);
			}
		}

		// Token: 0x060011DA RID: 4570 RVA: 0x00316640 File Offset: 0x00314840
		public virtual void addExpressionProcessor(AbstractProcessor p)
		{
			if (this.expressionProcessors == null)
			{
				this.expressionProcessors = new List<AbstractProcessor>();
			}
			this.expressionProcessors.Add(p);
		}

		// Token: 0x17000347 RID: 839
		// (get) Token: 0x060011DB RID: 4571 RVA: 0x00316661 File Offset: 0x00314861
		public virtual IList<AbstractProcessor> ExpressionProcessors
		{
			get
			{
				if (this.expressionProcessors == null)
				{
					this.expressionProcessors = new List<AbstractProcessor>();
				}
				return this.expressionProcessors;
			}
		}

		// Token: 0x060011DC RID: 4572 RVA: 0x0031667C File Offset: 0x0031487C
		public virtual void addSpecialProcessor(AbstractProcessor p)
		{
			if (this.specialProcessors == null)
			{
				this.specialProcessors = new List<AbstractProcessor>();
			}
			this.specialProcessors.Add(p);
		}

		// Token: 0x17000348 RID: 840
		// (get) Token: 0x060011DD RID: 4573 RVA: 0x0031669D File Offset: 0x0031489D
		public virtual IList<AbstractProcessor> SpecialProcessors
		{
			get
			{
				if (this.specialProcessors == null)
				{
					this.specialProcessors = new List<AbstractProcessor>();
				}
				return this.specialProcessors;
			}
		}

		// Token: 0x17000349 RID: 841
		// (get) Token: 0x060011DE RID: 4574 RVA: 0x003166B8 File Offset: 0x003148B8
		// (set) Token: 0x060011DF RID: 4575 RVA: 0x003166C0 File Offset: 0x003148C0
		public virtual string SessionId
		{
			get
			{
				return this.sessionId;
			}
			set
			{
				this.sessionId = value;
			}
		}

		// Token: 0x040013CE RID: 5070
		private IList<AbstractProcessor> expressionProcessors;

		// Token: 0x040013CF RID: 5071
		private IList<AbstractProcessor> specialProcessors;

		// Token: 0x040013D0 RID: 5072
		private string sessionId;
	}
}
